package com.ljx.recruitment.interview.controller;

import com.ljx.recruitment.common.domain.vo.resp.ApiResult;
import com.ljx.recruitment.common.domain.vo.resp.PageResp;
import com.ljx.recruitment.interview.domain.dto.ResumeItmDto;
import com.ljx.recruitment.interview.domain.vo.resp.ResumeResp;
import com.ljx.recruitment.interview.domain.vo.req.ResumePageReq;
import com.ljx.recruitment.interview.domain.vo.req.ResumeSubmitReq;
import com.ljx.recruitment.interview.service.ResumeService;
import com.ljx.recruitment.security.annotation.ApiPermission;
import com.ljx.recruitment.security.common.PermissionConstant;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: LiJunXi
 * @Description:
 * @Date: 2024-11-02  21:05
 */
@Api(tags = "简历接口")
@RestController
@RequestMapping("/resume")
public class ResumeController {

    @Autowired
    private ResumeService resumeService;

    @ApiPermission(permissions = {PermissionConstant.RESUME_SUBMIT})
    @ApiOperation("初始化简历")
    @PostMapping("/init")
    public ApiResult<List<ResumeItmDto>> init(){
        return ApiResult.success(resumeService.init());
    }

    @ApiPermission(permissions = {PermissionConstant.RESUME_QUERY})
    @ApiOperation("获取简历配置信息")
    @GetMapping("/item/info/{id}")
    public ApiResult<ResumeResp> getInfo(@PathVariable("id") Long resumeItemId){
        return ApiResult.success(resumeService.getInfo(resumeItemId));
    }

    @ApiPermission(permissions = {PermissionConstant.RESUME_QUERY})
    @ApiOperation("获取简历配置分页")
    @GetMapping("/item/page")
    public ApiResult<PageResp<ResumeResp>> getPage(ResumePageReq req) {
        return ApiResult.success(resumeService.getPage(req));
    }

    @ApiPermission(permissions = {PermissionConstant.RESUME_SUBMIT})
    @ApiOperation("创建/修改简历配置")
    @PostMapping("/item/submit")
    public ApiResult<ResumeResp> submit(@Validated @RequestBody ResumeSubmitReq req){
        return ApiResult.success(resumeService.submit(req));
    }



}
